﻿using Time;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace Time.Test
{
    [TestClass()]
    public class TimeTest
    {
        [TestMethod()]
        public void TimeConstructorTest()
        {
            Time target = new Time();
            Assert.AreEqual(0, target.Hours);
            Assert.AreEqual(0, target.Minutes);
        }

        [TestMethod()]
        public void ToStringTest()
        {
            Time target = new Time(12, 78);
            string expected = "The time is 13:18";
            string actual;
            actual = target.ToString();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void TimeConstructorTest1()
        {
            int hours = -13;
            Time target = new Time(hours);
            Assert.AreEqual(11, target.Hours);
            Assert.AreEqual(0, target.Minutes);
        }

        [TestMethod()]
        public void TimeConstructorTest2()
        {
            int hours = 27;
            int minutes = -40;
            Time target = new Time(hours, minutes);
            Assert.AreEqual(2, target.Hours);
            Assert.AreEqual(20, target.Minutes);
        }

        [TestMethod()]
        public void op_AdditionTest()
        {
            Time first = new Time(12, 45);
            Time second = new Time(2, 23);
            Time actual;
            actual = (first + second);
            Assert.AreEqual(15, actual.Hours);
            Assert.AreEqual(8, actual.Minutes);
        }

        [TestMethod()]
        public void op_DecrementTest()
        {
            Time first = new Time(12, 0);
            Time actual;
            actual = --(first);
            Assert.AreEqual(11, actual.Hours);
            Assert.AreEqual(59, actual.Minutes);
        }

        [TestMethod()]
        public void op_DecrementTest2()
        {
            Time first = new Time(00, 0);
            Time actual;
            actual = --(first);
            Assert.AreEqual(23, actual.Hours);
            Assert.AreEqual(59, actual.Minutes);
        }

        [TestMethod()]
        public void op_IncrementTest()
        {
            Time first = new Time(11, 59);
            Time actual;
            actual = ++(first);
            Assert.AreEqual(12, actual.Hours);
            Assert.AreEqual(00, actual.Minutes);
        }

        [TestMethod()]
        public void op_SubtractionTest()
        {
            Time first = new Time(2, 13);
            Time second = new Time(11, 59);
            Time actual;
            actual = (first - second);
            Assert.AreEqual(14, actual.Hours);
            Assert.AreEqual(14, actual.Minutes);
        }

        [TestMethod()]
        public void op_AdditionTest1()
        {
            Time first = new Time(2, 33);
            int moreMinutes = 40;
            Time actual;
            actual = (first + moreMinutes);
            Assert.AreEqual(3, actual.Hours);
            Assert.AreEqual(13, actual.Minutes);
        }

        [TestMethod()]
        public void op_SubtractionTest1()
        {
            Time first = new Time(0, 33);
            int moreMinutes = 45;
            Time actual;
            actual = (first - moreMinutes);
            Assert.AreEqual(23, actual.Hours);
            Assert.AreEqual(48, actual.Minutes);
        }
    }
}
